#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
#include <string.h>

size_t my_strlen(const char* p)
{
	size_t count = 0;

	while (*p != '\0')
	{
		count++;
		p++;
	}
	return count;
}

int main1()
{
	char str[] = "abcdef";
	int n = strlen(str);
	int m = my_strlen(str);
	printf("%d\n", n);
	printf("%d\n", m);
	return 0;
}
///


char* my_strcpy(char* dest,const char* src)
{
	char* ret = dest;
	while (*src != '\0')
	{
		*dest = *src;
		dest++;
		src++;
	}
	*dest = *src;//copy \0
	return ret;
}

char* my_strcat(char* dest, const char* src)
{
	char* ret = dest;
	while (*dest != '\0')
	{
		dest++;
	}
	while (*src != '\0')
	{
		*dest = *src;
		dest++;
		src++;
	}
	*dest = *src;//copy \0
	return ret;
}

int main2()
{
	char str1[20] = "abcdef";
	char str2[20] = "xxxxxxxxxx";
	char str3[20] = "xxxxxxxxxx";
	my_strcpy(str2,str1);
	printf("%s\n", str2);
	my_strcat(str3, str1);
	printf("%s\n", str3);
	return 0;
}
///

int my_strcmp(const char* dest, const char* src)
{
	while (*dest == *src)
	{
		if (*dest == "\0")
		{
			return 0;
		}
		dest++;
		src++;
	}
	return *dest - *src;
}
int main()
{
	char str1[20] = "abcdef";
	char str2[20] = "abcdeg";
	int n = my_strcmp(str2, str1);
	printf("%d\n", n);
	return 0;
}
